Skip to content

fix(secure): use protojson serializer for organization updates#724

Merged
tembleking merged 2 commits intomasterfrom
fix/organization-update-serializer
Apr 9, 2026
Merged

fix(secure): use protojson serializer for organization updates#724
tembleking merged 2 commits intomasterfrom
fix/organization-update-serializer

Conversation

@tembleking
Copy link
Copy Markdown
Member

Summary

UpdateOrganizationSecure was using json.Marshal (standard Go JSON) which produces snake_case field names (management_account_id, organization_root_id), while the cloudauth backend expects protobuf JSON with camelCase fields (managementAccountId, organizationRootId). This caused the API to return 500 on every update attempt, making organization updates impossible.

The create path already used the correct marshalCloudauthProto serializer. This aligns the update path to use the same one.

UpdateOrganizationSecure was using json.Marshal which produces snake_case
field names (management_account_id, organization_root_id), while the
cloudauth backend expects protobuf JSON with camelCase fields
(managementAccountId, organizationRootId). This caused the API to return
500 on every update attempt, making organization updates impossible.

The create path already used the correct marshalCloudauthProto serializer.
@tembleking tembleking requested a review from a team as a code owner April 8, 2026 14:38
Copilot AI review requested due to automatic review settings April 8, 2026 14:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a critical bug in the UpdateOrganizationSecure method where it was incorrectly using the standard JSON serializer (json.Marshal) instead of the protobuf JSON serializer (protojson.Marshal). This caused API requests to be sent with snake_case field names (management_account_id, organization_root_id) instead of the camelCase field names (managementAccountId, organizationRootId) that the cloudauth backend expects, resulting in 500 errors on all organization update attempts. The fix aligns the update path with the already-correct create path.

Changes:

  • Fixed UpdateOrganizationSecure to use c.marshalCloudauthProto() instead of Marshal()
  • Added comprehensive test TestUpdateOrganizationSecureUsesCamelCase that verifies the request body uses camelCase field names

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
sysdig/internal/client/v2/organization.go Changed marshal serializer in UpdateOrganizationSecure from standard JSON to protobuf JSON
sysdig/internal/client/v2/organization_test.go Added test to verify UpdateOrganizationSecure uses camelCase field names in request payload

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@tembleking tembleking merged commit 95715d2 into master Apr 9, 2026
179 checks passed
@tembleking tembleking deleted the fix/organization-update-serializer branch April 9, 2026 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants